package org.example.contronller;

import lombok.RequiredArgsConstructor;
import org.example.mapper.ProjectMapper;
import org.example.pojo.ProjectInfoParam;
import org.example.pojo.PromotionInfoIdsParam;
import org.example.pojo.PromotionInfoParam;
import org.example.pojo.Result;
import org.example.service.ProjectService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController//表示交给Spring管理哦
@RequestMapping("/project")//配置映射路径
@Validated//开启数据校验
@RequiredArgsConstructor
public class ProjectController {


    private final ProjectService projectService;
    /**
     * 查询项目信息
     * 推广状态:0-为推广,1已推广,2推广中,-1失败  参考枚举 对应的数字即可
     * 分页参数,必填项->
     *
     * @return
     */
    @PostMapping("/promotionInfo")
    public Result promotionInfo(@RequestBody PromotionInfoParam param) {
        return Result.success("查询成功", projectService.promotionInfo(param));
    }

    /**
     * 新增项目
     * 根据项目id数组查询对应的项目信息
     * 分页参数必填
     *
     * @return
     */
    @PostMapping("/promotionProjectByIds")
    public Result add(@RequestBody PromotionInfoIdsParam param) {

        return Result.success("查询成功", projectService.selectById(param));
    }

    /**
     * 标记项目,传入项目id->
     * */
    @GetMapping("/markProject/{projectId}")
    public Result markProject(@PathVariable("projectId") Integer projectId){
        return Result.success("标记成功",projectService.markProject(projectId));
    }

    /**
     * 取消标记
     * */
    @GetMapping("/cancelMarkProject/{projectId}")
    public Result cancelMarkProject(@PathVariable("projectId") Integer projectId){
        return Result.success("取消标记成功",projectService.cancelMarkProject(projectId));
    }

   //根据学校和专业获取学生信息  不需要参数 返回值 学校id 学校名称 专业id 专业名称  学校专业人数

    @PostMapping("/getSchoolStudentInfo")
    public Result getSchoolStudentInfo(){
        return Result.success("获取成功",projectService.getSchoolStudentInfo());
    }

    //获取指定专业注册人信息
    @PostMapping("/getMajorStudentInfo")
    public Result getMajorStudentInfo(){
        return Result.success("获取成功",projectService.getMajorStudentInfo());
    }



}
